package com.example.mobwe_project;


import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class BookPresentation extends Activity {

	//private MediaPlayer mp;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_book_presentation);
		
		Button bk=(Button)findViewById(R.id.button1);
		Button frw=(Button)findViewById(R.id.button2);
		
		frw.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				goForward();
				
			}
		});
		
		
		
		bk.setOnClickListener(new OnClickListener() {
		
				
			
			
			@Override
			public void onClick(View arg0) {
				goBack();
				
			}
		});
		 
		final ImageView imageView = (ImageView) findViewById(R.id.imageView1);
		final ImageView image = (ImageView) findViewById(R.id.imageView2);
		
		
		
		imageView.setOnClickListener(new OnClickListener() {
			
			public void onClick(View arg0) {
		
				
		Bitmap myImg = BitmapFactory.decodeResource(getResources(), R.drawable.pic1);

		Matrix matrix = new Matrix();
		matrix.postRotate(30);

		Bitmap rotated = Bitmap.createBitmap(myImg, 0, 0, myImg.getWidth(), myImg.getHeight(),
		        matrix, true);

		imageView.setImageBitmap(rotated);
			}
		});   
	
      
		
		image.setOnClickListener(new OnClickListener() {
			
			public void onClick(View arg0) {
				
		Bitmap myImg2 = BitmapFactory.decodeResource(getResources(), R.drawable.pic2);

		Matrix matrix = new Matrix();
		matrix.postRotate(50);

		Bitmap rotated = Bitmap.createBitmap(myImg2, 0, 0, myImg2.getWidth(), myImg2.getHeight(),
		        matrix, true);

		imageView.setImageBitmap(rotated);
			}
		});   
	
		
	}
	

	
	protected void goForward() {
		Intent forw=new Intent(this,NextPage.class);
		startActivity(forw);
		
	}




	protected void goBack() {
	Intent back=new Intent(this,MenuActivity.class);
	startActivity(back);
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_book_presentation, menu);
		return true;
	}

}